<!-- /* Description for file.
 * 招聘职位信息修改
 * @copyright     Copyright 2008-2010, PHInfo Services Inc. (http://www.phinfoservices.com)
 * @package       ues
 * @subpackage    ues/app/views/resources
 * @since         ues
 * @version       V0.0.1
 * @modifiedby   会兵2011年0705
 * @lastmodified  会兵2011年0705
 */
 -->

<?php
echo $html->css ( 'style' );
echo $html->css ( 'tab' );
echo $html->css ( 'jquery-validate/css/screen' );
?>


<script type="text/javascript">
//职能二级菜单
//$(document).ready(function(){
//	$("#RecruitpositionPromotion1").change(function(){
//		var CompetencyDroptoplist = $(this).val();
//		if(CompetencyDroptoplist!="")
//		{
//			$.post("<?php echo ROOT_WEB_PATH; ?>/competencies/getcompetencies/",{
//				Competency : $(this).val()
//				},function(data,textStatus){
//					 $("#RecruitpositionPromotion2:eq(0)>option").remove();
//					 $(data).find("aaa").each(function(){
//					//	 alert($(this).attr("name"));
//					 $("#RecruitpositionPromotion2:eq(0)").append("<option></option>");
//					 $("#RecruitpositionPromotion2:eq(0)>option:last").val($(this).attr("name")).html($(this).text());
//				  });
//				});
//		}
//	});
//	$("#RecruitpositionEditForm").bind("submit", function() { 
//		var value = "";
//		if($("#RecruitpositionPromotion1 option:selected").text()!="不限")
//		value = $("#RecruitpositionPromotion1 option:selected").text()+'_';
//		if($("#RecruitpositionPromotion2 option:selected").text()!="不选"&&$("#RecruitpositionPromotion2 option:selected").text()!="--")
//		value += $("#RecruitpositionPromotion2 option:selected").text()+'_';
//		$("#RecruitpositionPromotion").val(value); });
//});

//职能三层字段 级联菜单 //
//职能二级菜单
$(document).ready(function(){
	$("#CompanymanageCompetency1").change(function(){
		var CompetencyDroptoplist = $(this).val();
		if(CompetencyDroptoplist!="")
		{
			$("#CompanymanagePromotion").val($("#CompanymanageCompetency1 option:selected").text() + "_");
			$.post("<?php echo ROOT_WEB_PATH; ?>/competencies/getcompetencies/",{
				Competency : $(this).val()
				},function(data,textStatus){
					 $("#CompanymanageCompetency2:eq(0)>option").remove();
					 $(data).find("aaa").each(function(){
					 $("#CompanymanageCompetency2:eq(0)").append("<option></option>");
					 $("#CompanymanageCompetency2:eq(0)>option:last").val($(this).attr("name")).html($(this).text());
					 $("#CompanymanageCompetency3:eq(0)>option").remove();
					 $("#CompanymanageCompetency3:eq(0)").append("<option></option>");
					 $("#CompanymanageCompetency3:eq(0)>option:last").val("").html("不选");
				  });
				});
		}
		else
		{
			$("#CompanymanageCompetency2:eq(0)>option").remove();
			$("#CompanymanageCompetency2:eq(0)").append("<option></option>");
			$("#CompanymanageCompetency2:eq(0)>option:last").val("").html("不选");
			$("#CompanymanageCompetency3:eq(0)>option").remove();
			$("#CompanymanageCompetency3:eq(0)").append("<option></option>");
			$("#CompanymanageCompetency3:eq(0)>option:last").val("").html("不选");
			$("#CompanymanagePromotion").val("");
		}
	});
});
$(document).ready(function(){
	$("#CompanymanageCompetency2").change(function(){
		var list = $(this).val();
		if(list!="")
		{
			$("#CompanymanagePromotion").val($("#CompanymanageCompetency1 option:selected").text() + "_" + $("#CompanymanageCompetency2 option:selected").text() + "_");
			$.post("<?php echo ROOT_WEB_PATH; ?>/competencies/getcompetencies/",{
				Competency : $(this).val()
				},function(data,textStatus){
					 $("#CompanymanageCompetency3:eq(0)>option").remove();
					 $(data).find("aaa").each(function(){
					//	 alert($(this).attr("name"));
					 $("#CompanymanageCompetency3:eq(0)").append("<option></option>");
					 $("#CompanymanageCompetency3:eq(0)>option:last").val($(this).attr("name")).html($(this).text());					 
				  });
				});
		}
		else
		{
			$("#CompanymanageCompetency3:eq(0)>option").remove();
			$("#CompanymanageCompetency3:eq(0)").append("<option></option>");
			$("#CompanymanageCompetency3:eq(0)>option:last").val("").html("不选");
			$("#CompanymanagePromotion").val($("#CompanymanageCompetency1 option:selected").text() + "_");
		}
	});
	$("#CompanymanageCompetency3").change(function(){
		var list = $(this).val();
		if(list!="")
		{
			if($("#CompanymanageCompetency1 option:selected").text()!="不选"&&$("#CompanymanageCompetency1 option:selected").text()!="不限")
			$("#CompanymanagePromotion").val($("#CompanymanageCompetency1 option:selected").text() + "_" + $("#CompanymanageCompetency2 option:selected").text() + "_" + $("#CompanymanageCompetency3 option:selected").text());
			else
			$("#CompanymanagePromotion").val("");
		}
		else
		{
			if($("#CompanymanageCompetency1 option:selected").text()!="不选"&&$("#CompanymanageCompetency1 option:selected").text()!="不限")
			$("#CompanymanagePromotion").val($("#CompanymanageCompetency1 option:selected").text() + "_" + $("#CompanymanageCompetency2 option:selected").text() + "_");
			else
			$("#CompanymanagePromotion").val("");
		}
	});
});
	$(function()
	{
		$("#close").click(function(){		
			window.close();							
		});
		$("#quitfile").click(function(){	
			$("#fd").submit();
		 });
	});

	$(function()
			{
				$("#deletefile").click(function(){
					alert($("#recruitpositionsspecification").val());
					file = $("#recruitpositionsspecification");   
					file.after(file.clone());   
					file.remove(); 
//					$("#RecruitpositionSpecification").attr('value','11111');
//					$("#RecruitpositionSpecification").attr('text','11111');
				});
			});

	$(function(){
		//省份级联菜单 //
			$("#RecruitpositionProvinceId").change(function(){
				var workareaf = "" ;
				var list = $(this).val();
				$("#recruitpositionsaddressRequired").val($("#RecruitpositionProvinceId option:selected").text() + '-');
				if(list!="")
				{
					$.post("<?php echo ROOT_WEB_PATH; ?>/cities/getProvince/",{
						provicnceid : $(this).val()
						},
					function(data,textStatus){
							 $("#RecruitpositionCityId:eq(0)>option").remove();
							 $(data).find("aaa").each(function(){
							// alert($(this).attr("name"));
							 $("#RecruitpositionCityId:eq(0)").append("<option></option>");
							 $("#RecruitpositionCityId:eq(0)>option:last").val($(this).attr("name")).html($(this).text());

						  });
						if($("#RecruitpositionCityId option:selected").html() != null){		  
								 workareaf = $("#RecruitpositionProvinceId option:selected").text() + '-' +$("#RecruitpositionCityId option:selected").html();
						}
						else{
							workareaf = $("#RecruitpositionProvinceId option:selected").text() + '-';
						}
						$("#recruitpositionsaddressRequired").val(workareaf);
							  
					});
				}
			});
			$("#RecruitpositionCityId").change(function(){
				var citylist = $(this).val();
				if(citylist!="")
				{
					if($("#RecruitpositionProvinceId option:selected").text()!=""&&$("#RecruitpositionCityId option:selected").text()!="")
					$("#recruitpositionsaddressRequired").val($("#RecruitpositionProvinceId option:selected").text() + "-" + $("#RecruitpositionCityId option:selected").text());
					else
					$("#recruitpositionsaddressRequired").val("");
				}
				else
				{
					if($("#RecruitpositionProvinceId option:selected").text()!=""&&$("#RecruitpositionProvinceId option:selected").text()!="")
					$("#recruitpositionsaddressRequired").val($("#RecruitpositionProvinceId option:selected").text() + "-");
					else
					$("#recruitpositionsaddressRequired").val("");
				}
			});
	});
</script>

<!-- 当前位置-->
<?php echo $form->create('Companymanage',array('action'=>'editposition','type'=> 'post','enctype'=>'multipart/form-data'));?>
<?php echo $form->hidden('table',array('id'=>'table','default'=>$table));?>	
<div class="tabflex">
<fieldset><legend><?php __('职位修改');?></legend>
<table width="100%" cellspacing="0" cellpadding="0" border="0"
	style="text-align: left">
		<?php 
			echo $form->hidden('id',array('value'=>$data['Recruitposition']['id']));
		?>
		<?php 
			echo $form->hidden('fileid',array('value'=>$data['Recruitposition']['specification']));
		?>
		<?php 
			echo $form->hidden('companymanage_id',array('value'=>$data['Recruitposition']['companymanage_id']));
		?>
		<tr>
		<td width="50"></td>
		<td width="100"><?php __('职位名称');?>:
			<font color="red" id="name">
				<?php if($fields['name'] == 1 && $fields['name'] !=null){echo "*";}?>
			</font>	
		</td>
		<td width="230">
		<?php 
			echo $form->input('name',array('label'=>false,'value'=>$data['Recruitposition']['name'],'id'=>'recruitpositionsname'));
		?>
		</td>
		<td width="230"></td>
		<td></td>
		</tr>
		<tr>
		<td width="50"></td>
		<td width="100"><?php __('职    能');?>:
			<font color="red" id="promotion">
				<?php if($fields['promotion'] == 1 && $fields['promotion'] !=null){echo "*";}?>
			</font>	
		</td>
		<td><?php echo $form->input('promotion',array('label'=>false,'value'=>$data['Recruitposition']['promotion']));?></td>
		<!--职能下拉-->
		<td colspan="5">
		<?php $options = array();
					foreach($professions as $eachrecord)
					{
						$options[$eachrecord['Competency']['id']] = $eachrecord['Competency']['name'];
					}
					echo $form->input('competency1',array('empty' =>'不选','options'=>$options,'label'=>false,'div'=>false,'class'=>'TextBoxE1'));
				?>

		<?php 
			echo $form->input('competency2',array('options'=>array('0'=>'不选'),'label'=>false,'div'=>false,'class'=>'TextBoxE1'));
		?>

		<?php 
			echo $form->input('competency3',array('options'=>array('0'=>'不选'),'label'=>false,'div'=>false,'class'=>'TextBoxE1'));
		?>
		</td>
		</tr>
		<!--<tr>
		<td width="50"></td>
		<td width="100"><?php __('职    能');?>:
		
		</td>
		<td width="230">
		<?php 
			$options = array();
			foreach($professions as $eachrecord)
			{
				$options[$eachrecord['Competency']['id']] = $eachrecord['Competency']['name'];
			}
			echo $form->input('promotion1',array('empty' =>'不限','options'=>$options,'label'=>false,'div'=>false,'class'=>'TextBoxE1'));	
		?>
		</td>
		<td >
		<?php echo $form->input('promotion2',array('options'=>array('0'=>'--'),'label'=>false,'div'=>false,'class'=>'TextBoxE1'));		
				?>
		</td>
		<?php 
			echo $form->hidden('promotion');
		?>
		经    理
		</tr>
		--><tr>
		<td width="50"></td>
		<td width="100"><?php __('经    理');?>:</td>
		<td  colspan="3">
		<?php 	
			echo $form->input('manage',array('label'=>false,'value'=>$data['Recruitposition']['manage'],'class' => 'TextBoxE1 txtOut'));
		?> 
		</td>
		</tr>
		<tr>
		<!--性别-->
		<td width="50"></td>
		<td width="100"><?php __('性别要求');?>:</td>
		<td  colspan="3">
		<?php echo $form->input('sexRequired',
				array(
				'options'=>array(''=>'未知','男'=>'男','女'=>'女'),
				'label'=>false,'div'=>false,'class'=>'TextBoxE1','default'=>$data['Recruitposition']['sexRequired']));		
		?>
		</td>
		</tr>
		<tr>
		<td width="50"></td>
		<td width="100"><?php __('年龄要求');?>:</td>
		<td>
			<?php 	
				echo $form->input('minAgeRequired',array('label'=>false,'value'=>$data['Recruitposition']['minAgeRequired'],'after'=>'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;至     '));
			?> 
		</td>
		<td>
			<?php 	
				echo $form->input('maxAgeRequired',array('label'=>false,'value'=>$data['Recruitposition']['maxAgeRequired']));
			?> 
			
		</td>
		<td></td>
		</tr>
		<tr>
		<!--工作年限-->
		<td width="50"></td>
		<td width="100"><?php __('工作年限');?>:</td>
		<td>
			<?php 	
				echo $form->input('minWorkingLifeRequired',array('label'=>false,'value'=>$data['Recruitposition']['minWorkingLifeRequired'],'after'=>'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;至     '));
			?> 
		</td>
		<td>
			<?php 	
				echo $form->input('maxWorkingLifeRequired',array('label'=>false,'value'=>$data['Recruitposition']['maxWorkingLifeRequired']));
			?> 
		</td>
		<td></td>
		</tr>
		<tr>
		<!--学历-->
		<td width="50"></td>
		<td width="100"><?php __('学历要求');?>:</td>
		<td colspan="2">
			<?php 
				$options = array();
					foreach($advanceddegreeranks as $eachrecord)
					{
						$options[$eachrecord['Advanceddegreerank']['id']] = $eachrecord['Advanceddegreerank']['name'];
					}
					echo $form->input('advanceddegreerank_id',array('empty' =>'不限','options'=>$options,'label'=>false,'div'=>false,'class'=>'TextBoxE1','default'=>$data['Recruitposition']['advanceddegreerank_id']));
//					echo $form->input('advanceddegreerank_id',array('label'=>false,'value'=>$data['Recruitposition']['name']));		
				?>
		</td>
		<td></td>
		</tr>
		<tr>
		<!--外语要求-->
		<td width="50"></td>
		<td width="100"><?php __('外语要求');?>:</td>
		<td colspan="2">
			<?php 	
				echo $form->input('languageSkillsRequired',array('label'=>false,'value'=>$data['Recruitposition']['languageSkillsRequired'],'class'=>'TextBoxL txtOut'));
			?> 
		</td>
		<td></td>
		</tr>
		<tr>
		<!--行业要求-->
		<td width="50"></td>
		<td width="100"><?php __('行业要求');?>:</td>
		<td colspan="2">
			<?php 	
				echo $form->input('industryRequired',array('label'=>false,'value'=>$data['Recruitposition']['industryRequired'],'class'=>'TextBoxL txtOut'));
			?> 
		</td>
		<td></td>
		</tr>
		<tr>
		<td width="50"></td>
			<td width="100"><?php __('Address');//地    址?>:
				<font color="red" id="addressRequired">
				<?php if($fields['addressRequired'] == 1 && $fields['addressRequired'] !=null){echo "*";}?>
			</font>	
			</td><!--
			<td>
				<?php 	
					//echo $form->input('addressRequired',array('label'=>false,'id'=>'recruitpositionsaddressRequired','class'=>'TextBoxE1'));
				?> 
			</td>
			-->
			<td colspan="2">
			<?php echo $form->input('addressRequired',array('label'=>false,'div'=>false,'readonly'=>true,'id'=>'recruitpositionsaddressRequired','value'=>$data['Recruitposition']['addressRequired']));?>
			<?php $options = array();
					foreach($provinces as $eachrecord)
					{
						$options[$eachrecord['Province']['id']] = $eachrecord['Province']['name'];
					}
					echo $form->input('province_id',array('options'=>$options,'label'=>false,'div'=>false,'empty'=>'请选择','id'=>'RecruitpositionProvinceId'));
				?>
			<?php $options = array();
					foreach($cities as $eachrecord)
					{
						$options[$eachrecord['City']['id']] = $eachrecord['City']['name'];
					}
					echo $form->input('city_id',array('options'=>$options,'label'=>false,'div'=>false,'empty'=>'请选择','id'=>'RecruitpositionCityId'));
			 ?>	
			</td>	
		</tr>
		<!--<tr>
		地    址
		<td width="50"></td>
		<td width="100"><?php __('地    址');?>:</td>
		<td colspan="2">
			<?php 	
				echo $form->input('addressRequired',array('label'=>false,'value'=>$data['Recruitposition']['addressRequired'],'class'=>'TextBoxL txtOut'));
			?> 
		</td>
		<td></td>
		</tr>
		--><tr>
		<!--职位描述-->
		<td width="50"></td>
		<td width="100" style="vertical-align:top;"><?php __('职位描述');?>:
			<font color="red" id="description">
				<?php if($fields['description'] == 1 && $fields['description'] !=null){echo "*";}?>
			</font>	
		</td>
		<td colspan="2">
			<?php 	
				echo $form->input('description',array('type'=>'textarea','label'=>false,'value'=>$data['Recruitposition']['description'],'class'=>'areaStyle txtOut'));
			?> 
		</td>
		<td></td>
		</tr>
		<tr>
		<!--职位要求-->
		<td width="50"></td>
		<td width="100" style="vertical-align:top;"><?php __('职位要求');?>:
					<font color="red" id="otherRequired">
				<?php if($fields['otherRequired'] == 1 && $fields['otherRequired'] !=null){echo "*";}?>
			</font>	
		</td>
		<td colspan="2">
			<?php 	
				echo $form->input('otherRequired',array('type'=>'textarea','label'=>false,'value'=>$data['Recruitposition']['otherRequired'],'class'=>'areaStyle txtOut'));
			?> 
		</td>
		<td></td>
		</tr>
		<tr>
		<!--薪资福利-->
		<td width="50"></td>
		<td width="100" style="vertical-align:top;"><?php __('薪资福利');?>:
					<font color="red" id="salary">
				<?php if($fields['salary'] == 1 && $fields['salary'] !=null){echo "*";}?>
			</font>	
		</td>
		<td colspan="2">
			<?php 	
				echo $form->input('salary',array('type'=>'textarea','label'=>false,'value'=>$data['Recruitposition']['salary'],'class'=>'areaStyle txtOut'));
			?> 
		</td>
		<td></td>
		</tr>
		<tr>
		<!--职位备注-->
		<td width="50"></td>
		<td width="100" style="vertical-align:top;"><?php __('职位备注');?>:
					<font color="red" id="memo">
				<?php if($fields['memo'] == 1 && $fields['memo'] !=null){echo "*";}?>
			</font>	
		</td>
		<td colspan="2">
			<?php 	
				echo $form->input('memo',array('type'=>'textarea','label'=>false,'value'=>$data['Recruitposition']['memo'],'class'=>'areaStyle txtOut'));
			?> 
		</td>
		<td></td>
		</tr>
		<tr>
		<!--职位说明书-->
		<td width="50"></td>
		<td width="100"><?php __('职位说明书');?>:</td>
		<td>
			<?php 	
				echo $form->file('Specification',array('label'=>false,'name'=>'Specification','id'=>'recruitpositionsspecification'));
			?> 
		</td>
		<td><?php 	if(count($atts)>0)
					{	
						$dir="files-specification";
						echo $html->link($atts[0]['Attachment']['fileName'],
							'/recruitpositions/down/'.$dir.'/'.$atts[0]['Attachment']['filePath'],
							array('class'=>'view'));
					}
			?> 
			</td>
		<td>
		<?php echo $form->button('取消附件',array('class'=>'btn4','id'=>'deletefile'));?>
		<?php if(count($atts)>0)
					{	
						echo $form->button('删除附件',array('class'=>'btn4','id'=>'quitfile'));
					}?>
		</td>
		</tr>
</table>
</fieldset>

</div>
<table width="30%" cellspacing="0" cellpadding="0" border="0" style="text-align: left">
	<tr>
		<td width="50"></td>
		<td width="100"><?php echo $form->button('确定',array('type'=>'submit','class'=>'oksubmit'));?>  <!-- __('reset', true)取消-->
		<td width="100"><?php echo $form->button('关闭',array('class'=>'cancelbutton','id'=>'close'));?>  <!-- __('reset', true)取消-->
		</td>
	</tr>
</table>
<?php echo $form->end();?>
<form action="<?php echo ROOT_WEB_PATH; ?>/companymanages/quitfile" method="post" id="fd">
<input type="hidden" name="recruitpositionid" value="<?php echo $data['Recruitposition']['id'];?>"></input>
</form>

<script type="text/javascript">

//验证是否必填
function test(id)
{
	var srt = "font#" + id;
	var isValidate =  $(srt).text();
	var validate = $.trim(isValidate);
	if(validate == "*"){
		return true;
	} else {
		return false;
	}
}

//添加验证
$(document).ready(function() {
	$.validator.setDefaults({       
		 submitHandler: function(form) {   
		 form.submit();    
		}       
	});    
			
// validate signup form on keyup and submit
$("#CompanymanageEditpositionForm").validate({
rules: {
"data[Companymanage][name]": {
required: test("name"),string:true,stringMinLength:0,stringMaxLength:50
},
"data[Companymanage][description]": {
required: test("description"),string:true,stringMinLength:0,stringMaxLength:200
},
"data[Companymanage][memo]": {
required: test("memo"),string:true,stringMinLength:0,stringMaxLength:50
},
"data[Companymanage][salary]": {
required: test("salary"),string:true,stringMinLength:0,stringMaxLength:50
},
"data[Companymanage][addressRequired]": {
required: test("addressRequired"),area:true,stringMinLength:0,stringMaxLength:50
},
"data[Companymanage][otherRequired]": {
required: test("otherRequired"),string:true,stringMinLength:0,stringMaxLength:50
},
"data[Companymanage][promotion1]": {
required: test("promotion"),selectNone:true
},
"data[Companymanage][manage]": {
required: false,string:true,stringMinLength:0,stringMaxLength:50
},
"data[Companymanage][minAgeRequired]" : {
required: false,number:true
},
"data[Companymanage][maxAgeRequired]" : {
required: false,number:true
},
"data[Companymanage][minWorkingLifeRequired]" : {
required: false,number:true
},
"data[Companymanage][maxWorkingLifeRequired]" : {
required: false,number:true
},
"data[Companymanage][languageSkillsRequired]": {
required: false,string:true,stringMinLength:0,stringMaxLength:50
},
"data[Companymanage][industryRequired]": {
required: false,string:true,stringMinLength:0,stringMaxLength:50
} 
},
focusInvalid:false,
onkeyup:false,
errorPlacement:function(error, element){
	error.appendTo(element.parent());
}
});
});
//验证结束
</script>
